#ifndef INC_RGBA_H
#define INC_RGBA_H

typedef float scalar_t;

class RGBAColor
{

public:

    scalar_t r;
    scalar_t g;
    scalar_t b;
    scalar_t a;

    RGBAColor(scalar_t R = 1, scalar_t G = 1, scalar_t B = 1, scalar_t A = 1) : r(R), g(G), b(B), a(A) {}
    RGBAColor(const RGBAColor &color) : r(color.r), g(color.g), b(color.b), a(color.a) {}

     //assignment
     const RGBAColor &operator=(const RGBAColor &color)
     {
          r = color.r;
          g = color.g;
          b = color.b;
          a = color.a;

          return *this;
     }

     //equality
     const bool operator==(const RGBAColor &color) const
     {
          return ((r == color.r) && (g == color.g) && (b == color.b) && (a == color.a));
     }

     //inequality
     const bool operator!=(const RGBAColor &color) const
     {
          return !(*this == color);
     }

     //add
     const RGBAColor operator+(const RGBAColor &color) const
     {
          return RGBAColor(r + color.r, g + color.g, b + color.b, a + color.a);
     }

     //add (opposite of negation)
     const RGBAColor operator+() const
     {    
          return RGBAColor(*this);
     }


     //subtraction
     const RGBAColor operator-(const RGBAColor& color) const
     {    
          return RGBAColor(r - color.r, g - color.g, b - color.b, a - color.a);
     }
     
     //self-multiply
     const RGBAColor &operator*=(const scalar_t &s)
     {
          r *= s;
          g *= s;
          b *= s;
          a *= s;
          
          return *this;
     }

     // scalar self-divecide
     const RGBAColor &operator/=(const scalar_t &s)
     {
          const float recip = 1/s; // for speed, one divecision

          r *= recip;
          g *= recip;
          b *= recip;
          a *= recip;

          return *this;
     }

     // post multiply by scalar
     const RGBAColor operator*(const scalar_t &s) const
     {
          return RGBAColor(r*s, g*s, b*s, a*s);
     }

     // pre multiply by scalar
     friend inline const RGBAColor operator*(const scalar_t &s, const RGBAColor &color)
     {
          return color*s;
     }

     // divecide by scalar
     const RGBAColor operator/(scalar_t s) const
     {
          s = 1/s;

          return RGBAColor(s*r, s*g, s*b, s*a);
     }

};

#endif
